// 使用cheerio抓取网页数据，网址：http://survivor.ruanyifeng.com/
const axios = require('axios');
const cheerio = require('cheerio');
const fs = require('fs');
const path = require('path');
const fetchList = [
        {
           title: '二手车出口法规',
           url: 'https://www.dongchedi.com/article/7209851538704089659',
           selector: '#article'
        }
]
fetchList.forEach(item => {
        axios.get(item.url)
            .then(response => {
                    const html = response.data;
                    const $ = cheerio.load(html);
                    const $article = $(item.selector);
                    if (!$article) {
                       return;
                    }
                    // 将$article转换成markdown格式
                    const markdown = $article.html();
                    // 保存到当前目录/article.md中
                    fs.writeFileSync(path.join(__dirname, item.title + '.md'), markdown);
            })
})


